home *** CD-ROM | disk | FTP | other *** search
- if !?argv[1]
- label usage
- echo usage: hex number
- exit 10
- endif
- if !numeric(argv[1])
- goto usage
- endif
- local number result
- if number=argv[1]
- result=""
- else
- result="0"
- endif
- while number
- result=cat(substr('0123456789ABCDEF',(number&15)+1,1),"$result")
- number=(number>>4)&0x0fffffff
- endwhile
- echo $result
- exit 0
- # Hex - convert a decimal number to an hex string. Normally, strings
- # which contain only digits are considered to be numeric and are
- # therefore subject to loss of leading zeros; this is why result is
- # quoted in the loop.
- # Hex is presented as is; no warrantee is either expressed or implied
- # as to it's suitability to any purpose whatsoever. You assume all the
- # risk for all damage, even if caused by a defect in the software, no
- # matter how awful.
-